home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-03-15 | 34.2 KB | 1,138 lines |
- %%
- %% This is file `feynmf.mf', generated
- %% on <1995/3/4> with the docstrip utility (2.2i).
- %%
- %% The original source files were:
- %%
- %% feynmf.dtx (with options: `base')
- %%
- %% Copyright (C) 1989, 1990, 1992-1995 by Thorsten.Ohl@Physik.TH-Darmstadt.de
- %%
- %% This file is NOT the source for feynmf, because almost all comments
- %% have been stripped from it. It is NOT the preferred form of feynmf
- %% for making modifications to it.
- %%
- %% Therefore you can NOT redistribute and/or modify THIS file. You can
- %% however redistribute the complete source (feynmf.dtx and feynmf.ins)
- %% and/or modify it under the terms of the GNU General Public License as
- %% published by the Free Software Foundation; either version 2, or (at
- %% your option) any later version.
- %%
- %% Feynmf is distributed in the hope that it will be useful, but
- %% WITHOUT ANY WARRANTY; without even the implied warranty of
- %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- %% GNU General Public License for more details.
- %%
- %% You should have received a copy of the GNU General Public License
- %% along with this program; if not, write to the Free Software
- %% Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- %%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %% \CheckSum{553}
- %% \CharacterTable
- %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
- %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
- %% Digits \0\1\2\3\4\5\6\7\8\9
- %% Exclamation \! Double quote \" Hash (number) \#
- %% Dollar \$ Percent \% Ampersand \&
- %% Acute accent \' Left paren \( Right paren \)
- %% Asterisk \* Plus \+ Comma \,
- %% Minus \- Point \. Solidus \/
- %% Colon \: Semicolon \; Less than \<
- %% Equals \= Greater than \> Question mark \?
- %% Commercial at \@ Left bracket \[ Backslash \\
- %% Right bracket \] Circumflex \^ Underscore \_
- %% Grave accent \` Left brace \{ Vertical bar \|
- %% Right brace \} Tilde \~}
- %%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- if known cmbase:
- errhelp
- "feynmf will only work with plain Metafont, as described in the book.";
- errmessage "feynmf: CMBASE detected. Please use the PLAIN base.";
- forever:
- errmessage "No use in trying! You'd better eXit now ...";
- errorstopmode;
- endfor
- fi
- vardef parse_RCS (suffix RCS) (expr s) =
- save n, c;
- numeric n, RCS[];
- string c;
- RCS[0] := 0;
- for n = 1 upto length (s):
- c := substring (n-1,n) of s;
- exitif ((RCS[0] > 0) and (c = " "));
- if ((c = "0") or (c = "1") or (c = "2")
- or (c = "3") or (c = "4") or (c = "5")
- or (c = "6") or (c = "7") or (c = "8")
- or (c = "9")):
- if RCS[0] = 0:
- RCS[0] := 1;
- RCS[RCS[0]] := 0;
- fi
- RCS[RCS[0]] := 10 * RCS[RCS[0]] + scantokens (c);
- elseif c = ".":
- RCS[0] := RCS[0] + 1;
- RCS[RCS[0]] := 0;
- else:
- fi
- endfor
- enddef;
- vardef require_RCS_revision expr s =
- save n, TeX_rev, mf_rev;
- numeric n;
- parse_RCS (TeX_rev, s);
- parse_RCS (mf_rev, "1.10");
- for n = 1 upto min (2, TeX_rev[0], mf_rev[0]):
- if TeX_rev[n] > mf_rev[n]:
- errhelp
- "Your version of `feynmf.sty' is higher that of your `feynmf.mf'.";
- errmessage "feynmf: Metafont macros out of date";
- elseif TeX_rev[n] < mf_rev[n]:
- errhelp
- "Your version of `feynmf.mf' is higher that of your `feynmf.sty'.";
- errmessage "feynmf: LaTeX style out of date";
- fi
- exitif (TeX_rev[n] <> mf_rev[n]);
- endfor
- enddef;
- mode_setup;
- boolean feynmfwizard;
- feynmfwizard := false;
- thin#:=1pt#; % dimension of the lines
- thick#:=2thin#;
- arrow_len# := 4mm#;
- arrow_ang := 15;
- curly_len#:=3mm#;
- dash_len#:=3mm#; % 'photon' lines
- dot_len#:=2mm#; % 'photon' lines
- wiggly_len#:=4mm#; % 'photon' lines
- wiggly_slope:=60;
- shade_black#:=1pt#; % shading
- shade_white#:=2shade_black#;
- shade_angle:=60;
- decor_size#:=5mm#;
- dot_size#:=2thick#;
- define_blacker_pixels (thick, thin, shade_black, shade_white,
- dash_len, dot_len, wiggly_len, curly_len, arrow_len,
- decor_size, dot_size);
- def shrink expr s =
- begingroup
- if shrinkables <> "":
- save tmp_;
- forsuffixes $ = scantokens shrinkables:
- tmp_ := $.#;
- save $;
- $.# := s * tmp_;
- endfor
- define_blacker_pixels (scantokens shrinkables);
- fi
- enddef;
- def endshrink =
- endgroup
- enddef;
- string shrinkables;
- shrinkables := "";
- vardef addto_shrinkables (text l) =
- forsuffixes $ = l:
- shrinkables := shrinkables & "," & str $;
- endfor
- enddef;
- shrinkables := "thick,thin";
- addto_shrinkables (shade_black, shade_white);
- addto_shrinkables (dash_len, dot_len);
- addto_shrinkables (wiggly_len, curly_len);
- addto_shrinkables (arrow_len);
- addto_shrinkables (decor_size, dot_size);
- LaTeX_unitlength := mm;
- vardef count (text list) =
- forsuffixes $ = list: + 1 endfor
- enddef;
- vardef getopt (suffix opt) (expr s) =
- save n, argp, escape, anchor, skip;
- numeric opt.first, opt.last, n, anchor;
- string opt[], opt[]arg;
- boolean opt[]tainted, argp, escape, skip;
- opt.first := 0;
- opt.last := 0;
- opt[opt.last] := "";
- argp := false;
- escape := false;
- anchor := 0;
- skip := true;
- for n = 1 upto length (s):
- if skip and (substring (n-1, n) of s = " "):
- anchor := anchor + 1;
- else:
- skip := false;
- if not escape and (substring (n-1, n) of s = ","):
- if substring (n, n+1) of s = ",":
- escape := true;
- opt[opt.last]tainted := true;
- else:
- if argp:
- opt[opt.last]arg := substring (anchor, n-1) of s;
- else:
- opt[opt.last] := substring (anchor, n-1) of s;
- fi
- anchor := n;
- argp := false;
- skip := true;
- opt.last := opt.last + 1;
- fi
- elseif not argp and (substring (n-1, n) of s = "="):
- opt[opt.last] := substring (anchor, n-1) of s;
- anchor := n;
- argp := true;
- skip := true;
- elseif argp or (substring (n-1, n) of s <> " "):
- escape := false;
- fi
- fi
- endfor
- if argp:
- opt[opt.last]arg := substring (anchor, length s) of s;
- else:
- opt[opt.last] := substring (anchor, length s) of s;
- fi
- for n = opt.first upto opt.last:
- if known opt[n]tainted:
- if opt[n]tainted:
- opt[n]arg := untaint_string opt[n]arg;
- fi
- fi
- endfor
- enddef;
- vardef untaint_string suffix s =
- save n, anchor;
- numeric n, anchor;
- anchor := 0;
- for n = 1 upto length (s) - 1:
- if substring (n-1,n+1) of s = ",,":
- substring (anchor, n-1) of s &
- hide (anchor := n)
- fi
- endfor
- substring (anchor, length s) of s
- enddef;
- vardef split_string (suffix comp) (expr s) =
- save n, anchor;
- numeric comp.first, comp.last, n, anchor;
- string comp[];
- comp.first := 0;
- comp.last := 0;
- comp[comp.last] := "";
- anchor := 0;
- for n = 1 upto length (s):
- if substring (n-1,n) of s = ".":
- comp[comp.last] := substring (anchor, n-1) of s;
- comp.last := comp.last + 1;
- anchor := n;
- fi
- endfor
- comp[comp.last] := substring (anchor, length s) of s;
- enddef;
- vardef match_prefix (expr prefix, s) =
- (prefix = substring (0, length prefix) of s)
- enddef;
- vardef match_option (expr s, option) =
- save sc, optionc, n, i;
- numeric sc.first, sc.last, optionc.first, optionc.last;
- string sc[], optionc[];
- numeric n, i;
- split_string (sc, s);
- split_string (optionc, option);
- n := sc.last - sc.first;
- if n <> (optionc.last - optionc.first):
- false
- else:
- true
- for i = 0 upto n:
- and match_prefix (sc[sc.first+i],
- optionc[optionc.first+i])
- endfor
- fi
- enddef;
- def save_picture text t =
- save t; picture t; forsuffixes p=t: p:=nullpicture; endfor
- enddef;
- def begin_sketch =
- begingroup save_picture currentpicture;
- sketchlevel := sketchlevel+1;
- enddef;
- def end_sketch =
- sketchlevel := sketchlevel-1;
- sketchpad[sketchlevel] := currentpicture;
- endgroup
- enddef;
- picture sketchpad[];
- sketchlevel := 1;
- vardef use_sketch text t =
- addto currentpicture also (sketchpad[sketchlevel] t)
- enddef;
- vardef shade expr p_arg =
- save x,y,d,p,currentpen; path p; pen currentpen; % push pen!
- pickup pencircle scaled shade_black;
- p = p_arg rotated - shade_angle; % calculate enclosing rectangle
- x2' = x3' = xpart directionpoint up of p; % (rotated by |shade_angle|).
- x1' = x4' = xpart directionpoint down of p;
- y1' = y2' = ypart directionpoint right of p;
- y3' = y4' = ypart directionpoint left of p;
- forsuffixes $=1,2,3,4: z$ = z$' rotated shade_angle; endfor
- d = abs(z1-z4); % height.
- begin_sketch % fill rectangle with lines.
- for k=shade_white/d step (shade_white+shade_black)/d
- until 1 - shade_white/d:
- cutdraw k[z1,z4] -- k[z2,z3];
- endfor
- cullit;
- fill p_arg;
- unfill z1--z2--z3--z4--cycle;
- cullit;
- end_sketch;
- use_sketch;
- enddef;
- vardef hatch expr p =
- shade p;
- save a;
- a = shade_angle;
- save shade_angle;
- shade_angle = a + 90;
- shade p;
- enddef;
- vardef shadedraw expr p =
- shade p;
- draw p;
- enddef;
- vardef hatchdraw expr p =
- hatch p;
- draw p;
- enddef;
- vardef arrow expr p =
- save t, a, z_, ap_, tip;
- numeric t[], a;
- pair z_, tip;
- path ap_;
- a = angle direction .5 length(p) of p;
- z_ = point .5 length(p) of p;
- (t1,whatever) = p intersectiontimes
- (halfcircle scaled 2/3arrow_len rotated (a+90) shifted z_);
- (t2,whatever) = p intersectiontimes
- (halfcircle scaled 4/3arrow_len rotated (a-90) shifted z_);
- if t1 = -1: t1 := 0; fi
- if t2 = -1: t2 := length p; fi
- tip = point t2 of p;
- ap_ = subpath (t1,t2) of p shifted -tip;
- (ap_ rotated arrow_ang
- forced_join reverse ap_ rotated -arrow_ang
- -- cycle) shifted tip
- enddef;
- tertiarydef p forced_join q =
- subpath (0, length p - 1) of p
- & point (length p - 1) of p
- .. controls postcontrol (length p - 1) of p
- and precontrol infinity of p
- .. .5[point infinity of p, point 0 of q]
- .. controls postcontrol 0 of q and precontrol 1 of q
- .. point 1 of q
- & subpath (1, infinity) of q
- enddef;
- vardef cut_decors (suffix from) (expr p) (suffix to) =
- subpath (if known from.decor.shape:
- xpart (p intersectiontimes
- (from.decor.shape scaled from.decor.size
- shifted from.loc))
- else:
- 0
- fi,
- if known to.decor.shape:
- xpart (p intersectiontimes
- (to.decor.shape scaled to.decor.size
- shifted to.loc))
- else:
- infinity
- fi) of p
- enddef;
- vardef make_blob (expr z_arg, diameter) =
- save p,currentpen; path p; pen currentpen;
- pickup pencircle scaled thick;
- p = fullcircle scaled diameter shifted z_arg;
- shadedraw p;
- enddef;
- vardef draw_blob (expr z_arg, diameter) =
- if sketched_blob_diameter <> diameter: % drawn lately?
- begin_sketch make_blob (origin, diameter); end_sketch; % redo hard work!
- sketched_blob_diameter:= diameter; % record it
- fi
- use_sketch shifted z_arg; % the easy way ...
- enddef;
- def force_new_blob = sketched_blob_diameter := -1; enddef;
- force_new_blob; % initialize it.
- vardef pixlen (expr p, n) =
- for k=1 upto length(p): + segment_pixlen (subpath (k-1,k) of p, n) endfor
- enddef;
- vardef segment_pixlen (expr p, n) =
- for k=1 upto n: + abs (point k/n of p - point (k-1)/n of p) endfor
- enddef;
- vardef wiggly expr p_arg =
- save wpp;
- numeric wpp;
- wpp = ceiling (pixlen (p_arg, 10) / (wiggly_len * length(p_arg)));
- for k=0 upto wpp*length(p_arg) - 1:
- point k/wpp of p_arg
- {direction k/wpp of p_arg rotated wiggly_slope} ..
- point (k+.5)/wpp of p_arg
- {direction (k+.5)/wpp of p_arg rotated - wiggly_slope} ..
- endfor
- if cycle p_arg: cycle else: point infinity of p_arg fi
- enddef;
-
- vardef curly expr p_arg =
- save cpp;
- numeric cpp;
- cpp = ceiling (pixlen (p_arg, 10) / (curly_len * length(p_arg)));
- if cycle p_arg:
- for k=0 upto cpp*length(p_arg) - 1:
- point (k+.33)/cpp of p_arg
- {direction (k+.33)/cpp of p_arg rotated 90} ..
- point (k-.33)/cpp of p_arg
- {direction (k-.33)/cpp of p_arg rotated -90} ..
- endfor
- cycle
- else:
- point 0 of p_arg
- {direction 0 of p_arg rotated -90} ..
- for k=1 upto cpp*length(p_arg) - 1:
- point (k+.33)/cpp of p_arg
- {direction (k+.33)/cpp of p_arg rotated 90} ..
- point (k-.33)/cpp of p_arg
- {direction (k-.33)/cpp of p_arg rotated -90} ..
- endfor
- point infinity of p_arg
- {direction infinity of p_arg rotated 90}
- fi
- enddef;
- save vsty_hash;
- def style_def suffix s =
- vsty_hash.s := 1;
- expandafter quote vardef scantokens ("draw_" & str s)
- enddef;
- vardef vsty_exists suffix s =
- known vsty_hash.s
- enddef;
- vardef valid_style expr s =
- expandafter vsty_exists scantokens (s)
- enddef;
- style_def phantom expr p =
- \
- enddef;
- style_def phantom_arrow expr p =
- fill (arrow p);
- enddef;
- style_def plain expr p =
- draw p;
- enddef;
- style_def plain_arrow expr p =
- draw p;
- fill (arrow p);
- enddef;
- style_def dbl_plain expr p =
- draw_double p;
- enddef;
- style_def dbl_plain_arrow expr p =
- draw_double_arrow p;
- enddef;
- style_def wiggly expr p =
- draw (wiggly p);
- enddef;
- style_def dbl_wiggly expr p =
- draw_double (wiggly p);
- enddef;
- style_def curly expr p =
- draw (curly p);
- enddef;
- style_def dbl_curly expr p =
- draw_double (curly p);
- enddef;
- style_def dashes expr p_arg =
- save dpp;
- numeric dpp;
- dpp = ceiling (pixlen (p_arg, 10) / (dash_len * length(p_arg)));
- for k=0 upto dpp*length(p_arg) - 1:
- draw point k/dpp of p_arg ..
- point (k+.5)/dpp of p_arg;
- endfor
- enddef;
- style_def dbl_dashes expr p =
- save dpp;
- numeric dpp;
- dpp = ceiling (pixlen (p, 10) / (dash_len * length(p)));
- for k=0 upto dpp*length(p) - 1:
- draw_double point k/dpp of p ..
- point (k+.5)/dpp of p;
- endfor
- enddef;
- style_def dbl_dashes_arrow expr p =
- draw_dbl_dashes p;
- fill (arrow p);
- enddef;
- style_def dashes_arrow expr p =
- draw_dashes p;
- fill (arrow p);
- enddef;
- style_def dots expr p_arg =
- save dpp;
- numeric dpp;
- dpp = ceiling (pixlen (p_arg, 10) / (dot_len * length(p_arg)));
- for k=0 upto dpp*length(p_arg):
- drawdot point k/dpp of p_arg;
- endfor
- enddef;
- style_def dbl_dots expr p_arg =
- save dpp;
- numeric dpp;
- dpp = ceiling (pixlen (p_arg, 10) / (dot_len * length(p_arg)));
- begingroup
- pen oldpen;
- oldpen := currentpen;
- pickup oldpen scaled 3; % draw a thick linn
- for k=0 upto dpp*length(p_arg):
- drawdot point k/dpp of p_arg;
- endfor
- pickup oldpen;
- cullit;
- for k=0 upto dpp*length(p_arg):
- undrawdot point k/dpp of p_arg;
- endfor
- cullit; % and remove the stuffing
- endgroup;
- enddef;
- style_def dbl_dots_arrow expr p =
- draw_dbl_dots p;
- fill (arrow p);
- enddef;
- style_def dots_arrow expr p =
- draw_dots p;
- fill (arrow p);
- enddef;
- style_def double expr p_arg =
- begingroup
- pen oldpen;
- oldpen := currentpen;
- pickup oldpen scaled 3; % draw a thick linn
- draw p_arg;
- pickup oldpen;
- cullit; undraw p_arg; cullit; % and remove the stuffing
- endgroup;
- enddef;
- style_def double_arrow expr p =
- draw_double p;
- fill (arrow p);
- enddef;
- style_def vanilla expr p = draw_plain p enddef;
- style_def fermion expr p = draw_plain_arrow p enddef;
- style_def quark expr p = draw_plain_arrow p enddef;
- style_def electron expr p = draw_plain_arrow p enddef;
- style_def photon expr p = draw_wiggly p enddef;
- style_def boson expr p = draw_wiggly p enddef;
- style_def gluon expr p = draw_curly p enddef;
- style_def heavy expr p = draw_dbl_plain_arrow p enddef;
- style_def ghost expr p = draw_dots_arrow p enddef;
- style_def scalar expr p = draw_dashes_arrow p enddef;
- vardef fermion expr path_arg =
- fill arrow (path_arg);
- path_arg
- enddef;
- vardef photon expr path_arg =
- wiggly path_arg
- enddef;
- vardef gluon expr path_arg =
- curly path_arg
- enddef;
- tracingstats:=1;
- boolean vtracing;
- vtracing := false; % true
- def vinit =
- save vhash;
- numeric vlist.first, vlist.last;
- vlist.first := 1;
- vlist.last := 0;
- pair vlist[]loc, lambda[][];
- numeric vlist[]decor.size, vlist[]decor.sty, vlist[]decor.ang,
- vlist[]arc.first, vlist[]arc.last,
- vlist[]arc[], vlist[]arc[]lsr,
- vlist[]arc[]tns, vlist[]arc[]lbl.dist,
- vlist[]constr.first, vlist[]constr.last,
- vlist[]constr[];
- string vlist[]name, vlist[]lbl,
- vlist[]arc[]sty, vlist[]arc[]lbl, vlist[]arc[]lbl.side;
- numeric vlist[]lbl.ang, vlist[]lbl.side;
- path vlist[]decor.shape;
- enddef;
- def vertices =
- vlist.first upto vlist.last
- enddef;
- def varcs (text i) =
- vlist[i]arc.first upto vlist[i]arc.last
- enddef;
- def vconstr (text i) =
- vlist[i]constr.first upto vlist[i]constr.last
- enddef;
- vardef venter suffix v =
- if not vexists v:
- vlist.last := vlist.last + 1;
- vhash.v := vlist.last;
- vlist[vhash.v]name := str v;
- vlist[vhash.v]loc := (whatever,whatever);
- vlist[vhash.v]arc.first := 1;
- vlist[vhash.v]arc.last := 0;
- vlist[vhash.v]constr.first := 1;
- vlist[vhash.v]constr.last := 0;
- vlist[vhash.v]lbl := "";
- vlist[vhash.v]lbl.ang := whatever;
- vlist[vhash.v]lbl.dist := 3;
- fi
- enddef;
- vardef vexists suffix v =
- if known vhash.v: true else: false fi
- enddef;
- vardef vlookup suffix v =
- if vexists v: vhash.v else: 0 fi
- enddef;
- vardef vloc suffix v =
- vlist[vlookup v]loc
- enddef;
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- vardef vconnect (expr linesty) (text vl) =
- save from, nfrom, nto, nopt, sty;
- numeric from, nfrom, nto, nopt;
- string sty;
- getopt (opt, linesty);
- sty := opt[opt.first];
- if known opt[opt.first]arg:
- message "feynmf: line styles don't take arguments. "
- & "Argument `" & opt[opt.first]arg & "' ignored.";
- fi
- opt.first := opt.first + 1;
- forsuffixes to = vl:
- venter to;
- nto := vlookup to;
- if known nfrom:
- vlist[nfrom]arc.last := vlist[nfrom]arc.last + 1;
- vlist[nto]arc.last := vlist[nto]arc.last + 1;
- vlist[nfrom]arc[vlist[nfrom]arc.last] := nto;
- vlist[nto]arc[vlist[nto]arc.last] := nfrom;
- vlist[nfrom]arc[vlist[nfrom]arc.last]tns := 1;
- vlist[nto]arc[vlist[nto]arc.last]tns := 1;
- vlist[nfrom]arc[vlist[nfrom]arc.last]lsr := 0;
- vlist[nfrom]arc[vlist[nfrom]arc.last]lbl := "";
- vlist[nfrom]arc[vlist[nfrom]arc.last]lbl.side := "";
- vlist[nfrom]arc[vlist[nfrom]arc.last]lbl.dist := 3;
- for nopt = opt.first upto opt.last:
- if match_option (opt[nopt], "tension"):
- get_argument (opt[nopt], scantokens (opt[nopt]arg),
- vlist[nfrom]arc[vlist[nfrom]arc.last]tns);
- get_argument (opt[nopt], scantokens (opt[nopt]arg),
- vlist[nto]arc[vlist[nto]arc.last]tns);
- elseif match_option (opt[nopt], "left"):
- if known opt[nopt]arg:
- vlist[nfrom]arc[vlist[nfrom]arc.last]lsr
- := - scantokens (opt[nopt]arg);
- else:
- vlist[nfrom]arc[vlist[nfrom]arc.last]lsr := -1;
- fi
- elseif match_option (opt[nopt], "straight"):
- vlist[nfrom]arc[vlist[nfrom]arc.last]lsr := 0;
- ignore_argument (opt[nopt], opt[nopt]arg);
- elseif match_option (opt[nopt], "right"):
- if known opt[nopt]arg:
- vlist[nfrom]arc[vlist[nfrom]arc.last]lsr
- := scantokens (opt[nopt]arg);
- else:
- vlist[nfrom]arc[vlist[nfrom]arc.last]lsr := 1;
- fi
- elseif match_option (opt[nopt], "label"):
- get_argument (opt[nopt], opt[nopt]arg,
- vlist[nfrom]arc[vlist[nfrom]arc.last]lbl);
- elseif match_option (opt[nopt], "label.side"):
- get_argument (opt[nopt], opt[nopt]arg,
- vlist[nfrom]arc[vlist[nfrom]arc.last]lbl.side);
- elseif match_option (opt[nopt], "label.dist"):
- get_argument (opt[nopt], scantokens (opt[nopt]arg),
- vlist[nfrom]arc[vlist[nfrom]arc.last]lbl.dist);
- else:
- ignore_option (opt[nopt], opt[nopt]arg);
- fi
- endfor
- if valid_style sty:
- vlist[nfrom]arc[vlist[nfrom]arc.last]sty := sty;
- else:
- errhelp "feynmf: your linestyle is not recognizable, "
- & "check spelling and reprocess!";
- errmessage "feynmf: line style `" & sty & "' not known, "
- & "replaced by `vanilla'";
- vlist[nfrom]arc[vlist[nfrom]arc.last]sty := "vanilla";
- fi
- fi
- nfrom := nto;
- endfor
- enddef;
- vardef get_argument (expr opt, arg) (suffix variable) =
- if known arg:
- variable := arg;
- else:
- message "feynmf: option `" & opt & "' needs an argument. Ignored.";
- fi
- enddef;
- vardef ignore_argument (expr opt, arg) =
- if known arg:
- message "feynmf: option `" & opt & "' doesn't take an argument. "
- & "Argument `" & arg & "' ignored.";
- fi
- enddef;
- vardef ignore_option (expr opt, arg)=
- if known arg:
- message "feynmf: ignoring option " & opt & "=" & arg & ".";
- else:
- message "feynmf: ignoring option " & opt & ".";
- fi
- enddef;
- vardef vcyclen (expr sty) (suffix v) (expr n) =
- for $ = 1 upto n - 1:
- vconnect (sty, v[$], v[$+1]);
- endfor
- vconnect (sty, v[n], v[1]);
- enddef;
- vardef vrcyclen (expr sty) (suffix v) (expr n) =
- vconnect (sty, v[1], v[n]);
- for $ = n downto 2:
- vconnect (sty, v[$], v[$-1]);
- endfor
- enddef;
- vardef vforce (expr z) (suffix v) =
- venter v;
- vlist[vlookup v]loc := z;
- enddef;
- vardef vshift (expr z) (text vl) =
- forsuffixes $=vl:
- if vexists $:
- vlist[vlookup $]loc := vlist[vlookup $]loc + z;
- fi
- endfor
- enddef;
- vardef vconstraint (expr z) (text vl) =
- save nfrom, nto;
- numeric nfrom, nto;
- forsuffixes to = vl:
- venter to;
- nto := vlookup to;
- if known nfrom:
- vlist[nfrom]constr.last := vlist[nfrom]constr.last + 1;
- vlist[nto]constr.last := vlist[nto]constr.last + 1;
- vlist[nfrom]constr[vlist[nfrom]constr.last] := nto;
- vlist[nto]constr[vlist[nto]constr.last] := nfrom;
- vlist[nto]loc = vlist[nfrom]loc + z;
- fi
- nfrom := nto;
- endfor
- enddef;
- vardef vlabel (expr s) (suffix v) =
- venter v;
- vlist[vlookup v]lbl := s;
- enddef;
- vardef vvertex (expr vtxsty) (text vl) =
- save nopt, sty, arg;
- numeric nopt, arg;
- string sty;
- getopt (opt, vtxsty);
- forsuffixes v = vl:
- venter v;
- n := vlookup v;
- for nopt = opt.first upto opt.last:
- if match_option (opt[nopt], "label"):
- get_argument (opt[nopt], opt[nopt]arg, vlist[n]lbl);
- elseif match_option (opt[nopt], "label.angle"):
- get_argument (opt[nopt], scantokens (opt[nopt]arg),
- vlist[n]lbl.ang);
- elseif match_option (opt[nopt], "label.dist"):
- get_argument (opt[nopt], scantokens (opt[nopt]arg),
- vlist[n]lbl.dist);
- elseif match_option (opt[nopt], "decoration.shape"):
- if known opt[nopt]arg:
- if match_prefix (opt[nopt]arg, "circle"):
- vlist[n]decor.shape := fullcircle;
- elseif match_prefix (opt[nopt]arg, "square"):
- vlist[n]decor.shape := unitsquare shifted -(.5,.5);
- elseif match_prefix (opt[nopt]arg, "triangle"):
- vlist[n]decor.shape := polygon 3;
- elseif match_prefix (opt[nopt]arg, "triagon"):
- vlist[n]decor.shape := polygon 3;
- elseif match_prefix (opt[nopt]arg, "diamond"):
- vlist[n]decor.shape := polygon 4;
- elseif match_prefix (opt[nopt]arg, "tetragon"):
- vlist[n]decor.shape := polygon 4;
- elseif match_prefix (opt[nopt]arg, "pentagon"):
- vlist[n]decor.shape := polygon 5;
- elseif match_prefix (opt[nopt]arg, "hexagon"):
- vlist[n]decor.shape := polygon 6;
- elseif match_prefix (opt[nopt]arg, "triagram"):
- vlist[n]decor.shape := polygram 3;
- elseif match_prefix (opt[nopt]arg, "tetragram"):
- vlist[n]decor.shape := polygram 4;
- elseif match_prefix (opt[nopt]arg, "pentagram"):
- vlist[n]decor.shape := polygram 5;
- elseif match_prefix (opt[nopt]arg, "hexagram"):
- vlist[n]decor.shape := polygram 6;
- else:
- if feynmfwizard:
- vlist[n]decor.shape := scantokens(opt[nopt]arg);
- else:
- message "feynmf: invalid argument `" & opt[nopt]arg
- & "' to option `decor.shape'. Ignored.";
- fi
- fi
- else:
- message "feynmf: option `decor.shape' needs an argument. Ignored.";
- fi
- elseif match_option (opt[nopt], "decoration.filled"):
- get_argument (opt[nopt], scantokens (opt[nopt]arg),
- vlist[n]decor.sty);
- elseif match_option (opt[nopt], "decoration.size"):
- get_argument (opt[nopt], scantokens (opt[nopt]arg),
- vlist[n]decor.size);
- elseif match_option (opt[nopt], "decoration.angle"):
- get_argument (opt[nopt], scantokens (opt[nopt]arg),
- vlist[n]decor.ang);
- else:
- ignore_option (opt[nopt], opt[nopt]arg);
- fi
- endfor
- endfor
- enddef;
- vardef vvertexn (expr vtxsty) (suffix v) (expr n) =
- vvertex (vtxsty, vmklist (v, n));
- enddef;
- vardef vblob (expr bd) (text vl)=
- forsuffixes $=vl:
- if not vexists $: venter $; fi
- vlist[vlookup $]decor.shape := fullcircle;
- vlist[vlookup $]decor.size := bd;
- vlist[vlookup $]decor.sty := .5;
- endfor
- enddef;
- vardef vdot (text vl)=
- forsuffixes $=vl:
- if not vexists $: venter $; fi
- vlist[vlookup $]decor.shape := fullcircle;
- vlist[vlookup $]decor.size := dot_size;
- vlist[vlookup $]decor.sty := 1;
- endfor
- enddef;
- vardef vdotn (suffix v) (expr n) =
- vdot (vmklist (v, n));
- enddef;
- vardef vblobn (suffix v) (expr n) =
- vblob (vmklist (v, n));
- enddef;
- vardef left_gallery = (.1w,0)..(0,.5h)..(.1w,h) enddef;
- vardef right_gallery = (.9w,0)..(w,.5h)..(.9w,h) enddef;
- vardef bottom_gallery = (0,.1h)..(.5w,0)..(w,.1h) enddef;
- vardef top_gallery = (0,.9h)..(.5w,h)..(w,.9h) enddef;
- vardef surround_gallery =
- superellipse ((w,.5h), (.5w,h), (0,.5h), (.5w,0), .75)
- enddef;
- vardef vleft (text vl) = vdistribute (left_gallery, vl) enddef;
- vardef vright (text vl) = vdistribute (right_gallery, vl) enddef;
- vardef vbottom (text vl) = vdistribute (bottom_gallery, vl) enddef;
- vardef vtop (text vl) = vdistribute (top_gallery, vl) enddef;
- vardef vsurround (text vl) = vdistribute (surround_gallery, vl) enddef;
- vardef vdistribute (expr p) (text vl) =
- save numv, len, off;
- numeric numv, len, off;
- numv = count (vl);
- if cycle p: numv := numv + 1; fi
- len := length (p);
- if numv = 1:
- vforce (point len/2 of p, vl);
- else:
- off := 0;
- forsuffixes $ = vl:
- vforce (point off of p, $);
- off := off + len/(numv-1);
- endfor
- fi
- enddef;
- def vmklist (suffix v) (expr n) =
- for $ = 1 upto n-1: v[$], endfor v[n]
- enddef;
- vardef vleftn (suffix v) (expr n) =
- vleft (vmklist (v, n));
- enddef;
- vardef vrightn (suffix v) (expr n) =
- vright (vmklist (v, n));
- enddef;
- vardef vbottomn (suffix v) (expr n) =
- vbottom (vmklist (v, n));
- enddef;
- vardef vtopn (suffix v) (expr n) =
- vtop (vmklist (v, n));
- enddef;
- vardef vsurroundn (suffix v) (expr n) =
- vsurround (vmklist (v, n));
- enddef;
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- vardef vposition =
- for i = vertices:
- if unknown vlist[i]loc:
- origin = origin
- for j = varcs (i):
- + vlist[i]arc[j]tns * (vlist[i]loc - vlist[vlist[i]arc[j]]loc)
- endfor
- for j = vconstr (i):
- if i < vlist[i]constr[j]:
- + lambda[i][vlist[i]constr[j]]
- else:
- - lambda[vlist[i]constr[j]][i]
- fi
- endfor;
- fi
- endfor
- if vtracing: vdump; fi
- enddef;
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- vardef vdraw =
- for i = vertices:
- if not known vlist[i]loc:
- errhelp "Your graph specification was not complete (probably a "
- & "lone vertex). Check logic and reprocess!";
- errmessage "feynmf: vertex `" & vlist[i]name & "' not determined, "
- & "replaced by `(0,0)'.";
- vlist[i]loc := origin;
- fi
- if unknown vlist[i]decor.size:
- vlist[i]decor.size = decor_size;
- fi
- endfor
- for i = vertices:
- for j = varcs (i):
- if known vlist[i]arc[j]sty:
- vdraw_arc (vlist[i]arc[j]sty,
- cut_decors (vlist[i],
- vbuild_arc (vlist[i]arc[j]lsr,
- vlist[i]loc,
- vlist[vlist[i]arc[j]]loc),
- vlist[vlist[i]arc[j]]),
- vlist[i]arc[j]lbl);
- fi
- endfor;
- vdraw_vertex_label vlist[i];
- vdraw_vertex vlist[i];
- endfor
- enddef;
- vardef vbuild_arc (expr lsr, from, to) =
- if lsr = 0:
- from -- to
- else:
- from
- .. (1-lsr)/2 *(to rotatedabout (.5[from,to], 90))
- + (1+lsr)/2 * (to rotatedabout (.5[from,to], -90))
- .. to
- fi
- enddef;
- vardef vdraw_arc (expr sty, arc) (suffix lbl) =
- scantokens ("draw_" & sty) (arc);
- vdraw_arc_label (arc, lbl);
- enddef;
- vardef vdraw_arc_label (expr arc) (suffix lbl) =
- if lbl <> "":
- save _a, _z, _zz, _r;
- numeric _a;
- pair _z, _zz, _r;
- _z := point .5 length (arc) of arc;
- _r := direction .5 length (arc) of arc rotated - 90;
- if lbl.side = "left":
- _a := angle (-_r);
- elseif lbl.side = "right":
- _a := angle (_r);
- else:
- _zz = _z - .5[point 0 of arc, point infinity of arc];
- if ((_zz if length (_zz) > 0: / length (_zz) fi)
- dotprod _r) >= 0:
- _a := angle (_r);
- else:
- _a := angle (-_r);
- fi
- fi
- LaTeX_text (_z + lbl.dist * thick * dir _a, _a, lbl);
- fi
- enddef;
- vardef vdraw_vertex_label suffix v =
- if v.lbl <> "":
- save a;
- numeric a;
- if unknown v.lbl.ang:
- if v.loc = (.5w,.5h):
- a := 0;
- else:
- a := angle (v.loc - (.5w,.5h));
- fi
- else:
- a := v.lbl.ang;
- fi
- LaTeX_text (v.loc + v.lbl.dist * thick * dir a, a, v.lbl);
- fi
- enddef;
- vardef vdraw_vertex suffix v =
- save cmd;
- string cmd;
- if known v.decor.shape:
- cmd := "filldraw";
- if known v.decor.sty:
- if v.decor.sty = 0:
- cmd := "draw";
- elseif abs (v.decor.sty) >= 1:
- cmd := "filldraw";
- elseif v.decor.sty > 0:
- cmd := "shadedraw";
- else:
- cmd := "hatchdraw";
- fi
- fi
- scantokens (cmd) v.decor.shape
- if known v.decor.ang: rotated v.decor.ang fi
- scaled v.decor.size shifted v.loc;
- fi
- enddef;
- vardef polygon expr n =
- if n > 2:
- for i = 1 upto n:
- (.5up rotated (360i/n)) --
- endfor
- cycle
- else:
- fullcircle
- fi
- enddef;
- vardef polygram expr n =
- if n > 2:
- for i = 1 upto n:
- (.5up rotated (360i/n)) --
- (.2up rotated (360(i+.5)/n)) --
- endfor
- cycle
- else:
- fullcircle
- fi
- enddef;
- vardef LaTeX expr text =
- message (":" & jobname & "." & decimal charcode & ":" & text & "%%%")
- enddef;
- vardef LaTeX_text (expr z, a, txt) =
- LaTeX "\fmfL(" & (decimal (xpart z/LaTeX_unitlength)) & ","
- & (decimal (ypart z/LaTeX_unitlength)) & ","
- & (voctant a) & "){" & txt & "}";
- enddef;
- vardef voctant expr a =
- voctant_list[floor (a/45 + .5)]
- enddef;
- string voctant_list[];
- voctant_list[-4] := "r";
- voctant_list[-3] := "rt";
- voctant_list[-2] := "t";
- voctant_list[-1] := "lt";
- voctant_list[0] := "l";
- voctant_list[1] := "lb";
- voctant_list[2] := "b";
- voctant_list[3] := "rb";
- voctant_list[4] := "r";
- vardef vdump =
- message ">>>>> Vertices and arcs for diagram #" & decimal charcode
- & " of " & jobname & ".mf:";
- for i = vertices:
- message "> " & vlist[i]name & "=" & decimal_pair (vlist[i]loc)
- & ": #lines="
- & decimal (vlist[i]arc.last - vlist[i]arc.first + 1)
- if vlist[i]lbl <> "":
- & ", lbl=" & vlist[i]lbl
- & ", l.angle=" & decimal_ (vlist[i]lbl.ang)
- & ", l.dist=" & decimal_ (vlist[i]lbl.dist)
- fi
- & ".";
- endfor
- for i = vertices:
- for j = varcs (i):
- if known vlist[i]arc[j]sty:
- message "> " & vlist[i]name & "*" & vlist[vlist[i]arc[j]]name
- & ": " & vlist[i]arc[j]sty
- & ", tns=" & decimal_ (vlist[i]arc[j]tns)
- & ", lsr=" & decimal_ (vlist[i]arc[j]lsr)
- if vlist[i]arc[j]lbl <> "":
- & ", lbl=" & vlist[i]arc[j]lbl
- & ", l.side=" & vlist[i]arc[j]lbl.side
- & ", l.dist=" & decimal_ (vlist[i]arc[j]lbl.dist)
- fi
- & ".";
- fi
- endfor
- for j = vconstr (i):
- if i < vlist[i]constr[j]:
- save z;
- pair z;
- z = vlist[vlist[i]constr[j]]loc - vlist[i]loc;
- message "> " & vlist[i]name & "&"
- & vlist[vlist[i]constr[j]]name
- & ": " & decimal_pair (z);
- fi
- endfor;
- endfor
- enddef;
- vardef decimal_ (text n) =
- if known n: decimal n else: "?" fi
- enddef;
- vardef decimal_pair (text z) =
- "(" & decimal_ (xpart z) & "," & decimal_ (ypart z) & ")"
- enddef;
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- def show_diagram_ expr frame =
- if (screen_cols < w + 2 xpart frame) or (screen_rows < h + 2 ypart frame):
- screen_cols := w + 2 xpart frame;
- screen_rows := h + 2 ypart frame;
- openwindow currentwindow
- from origin to (screen_rows, screen_cols)
- at (- xpart frame, h + ypart frame);
- fi
- showit_;
- if showstopping > 0:
- stop "This is diagram #" & decimal charcode
- & ". Hit return to continue...";
- fi
- enddef;
- def show_diagram =
- def show_diagram =
- display blankpicture inwindow currentwindow;
- show_diagram_
- enddef;
- show_diagram_
- enddef;
- def show_all_diagrams expr frame =
- def showit = show_diagram frame enddef;
- displaying:=1;
- enddef;
- endinput;
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- \endinput
- %%
- %% End of file `feynmf.mf'.
-